package com.dlm.util;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.io.WKTReader;

/**
 * Created by chongsong on 15/2/2.
 * <mailto>chong.song@autonavi.com</mailto>
 */
public class GeomUtil {
    private static GeometryFactory geomFactory = new GeometryFactory();

    public static Point makePoint(double x,double y) {
        Point point = geomFactory.createPoint(new Coordinate(x, y));
        if (point.isValid()) {
            return point;
        }
        return null;
    }

    public static String toMysqlPointWkt(double x,double y){
        return "GeomFromText('" + "Point(" + x + " " + y + ")')";
    }

    public static void main(String[] args) {
        System.out.println(GeomUtil.makePoint(-3333331,1));;
        System.out.println(GeomUtil.toMysqlPointWkt(1, 1));
    }
}
